package sk.scerbak.ucl.usecases.serializer;

import com.google.inject.Inject;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition;
import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer;
import sk.scerbak.ucl.usecases.services.UsecasesGrammarAccess;

@SuppressWarnings("restriction")
public class AbstractUsecasesSyntacticSequencer extends AbstractSyntacticSequencer {

	protected UsecasesGrammarAccess grammarAccess;
	protected AbstractElementAlias match_UseCase_InterestsKeyword_3_5_0_q;
	protected AbstractElementAlias match_UseCase_MinimalGuaranteesKeyword_4_2_0_q;
	protected AbstractElementAlias match_UseCase_PreconditionsKeyword_4_0_0_q;
	protected AbstractElementAlias match_UseCase_SecondaryActorsKeyword_3_3_0_q;
	protected AbstractElementAlias match_UseCase_StakeholdersKeyword_3_4_0_q;
	protected AbstractElementAlias match_UseCase_SuccessGuaranteesKeyword_4_1_0_q;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (UsecasesGrammarAccess) access;
		match_UseCase_InterestsKeyword_3_5_0_q = new TokenAlias(false, true, grammarAccess.getUseCaseAccess().getInterestsKeyword_3_5_0());
		match_UseCase_MinimalGuaranteesKeyword_4_2_0_q = new TokenAlias(false, true, grammarAccess.getUseCaseAccess().getMinimalGuaranteesKeyword_4_2_0());
		match_UseCase_PreconditionsKeyword_4_0_0_q = new TokenAlias(false, true, grammarAccess.getUseCaseAccess().getPreconditionsKeyword_4_0_0());
		match_UseCase_SecondaryActorsKeyword_3_3_0_q = new TokenAlias(false, true, grammarAccess.getUseCaseAccess().getSecondaryActorsKeyword_3_3_0());
		match_UseCase_StakeholdersKeyword_3_4_0_q = new TokenAlias(false, true, grammarAccess.getUseCaseAccess().getStakeholdersKeyword_3_4_0());
		match_UseCase_SuccessGuaranteesKeyword_4_1_0_q = new TokenAlias(false, true, grammarAccess.getUseCaseAccess().getSuccessGuaranteesKeyword_4_1_0());
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		return "";
	}
	
	
	@Override
	protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
		if (transition.getAmbiguousSyntaxes().isEmpty()) return;
		List<INode> transitionNodes = collectNodes(fromNode, toNode);
		for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
			List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
			if(match_UseCase_InterestsKeyword_3_5_0_q.equals(syntax))
				emit_UseCase_InterestsKeyword_3_5_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_UseCase_MinimalGuaranteesKeyword_4_2_0_q.equals(syntax))
				emit_UseCase_MinimalGuaranteesKeyword_4_2_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_UseCase_PreconditionsKeyword_4_0_0_q.equals(syntax))
				emit_UseCase_PreconditionsKeyword_4_0_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_UseCase_SecondaryActorsKeyword_3_3_0_q.equals(syntax))
				emit_UseCase_SecondaryActorsKeyword_3_3_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_UseCase_StakeholdersKeyword_3_4_0_q.equals(syntax))
				emit_UseCase_StakeholdersKeyword_3_4_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_UseCase_SuccessGuaranteesKeyword_4_1_0_q.equals(syntax))
				emit_UseCase_SuccessGuaranteesKeyword_4_1_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     'Interests:'?
	 */
	protected void emit_UseCase_InterestsKeyword_3_5_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'Minimal guarantees:'?
	 */
	protected void emit_UseCase_MinimalGuaranteesKeyword_4_2_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'Preconditions:'?
	 */
	protected void emit_UseCase_PreconditionsKeyword_4_0_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'Secondary actors:'?
	 */
	protected void emit_UseCase_SecondaryActorsKeyword_3_3_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'Stakeholders:'?
	 */
	protected void emit_UseCase_StakeholdersKeyword_3_4_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'Success guarantees:'?
	 */
	protected void emit_UseCase_SuccessGuaranteesKeyword_4_1_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
